<?php

class Involved_LineChartModel extends BaseModel
{

    protected $table = 'calendar';

    /**
     * 锁定表
     */
    public function linechartpay($user_id,$yesr,$month,$day)
    {
        return DB::table($this->table)
            ->where(['user_id'=>$user_id,'year'=>$yesr,'month'=>$month,'day'=>$day])
            ->count();
    }

    /**
     * 锁定表
     */
    public function linechartone($user_id,$yesr,$month,$day)
    {
        return DB::table($this->table)
            ->where(['user_id'=>$user_id,'year'=>$yesr,'month'=>$month,'day'=>$day])
            ->first();
    }



    /**
     * app资产日历
     * @param $year
     * @param $month
     * @param $day
     * @param $user_id
     * @return mixed
     */
    public function CalendarD($year,$month,$day,$user_id)
    {
        return DB::table($this->table)
            ->select('money', 'profit_money', 'recharge_money','withdraw_money')
            ->where(['user_id' => $user_id,'year' => $year,'month' => $month,'day' => $day])
            ->get();

    }

    /**
     * app资产日历
     * @param $year
     * @param $month
     * @param $user_id
     * @return mixed
     */
    public function CalendarM($year,$month,$user_id)
    {
        return DB::table($this->table)
            ->select(DB::raw('sum(money) as money'),DB::raw('sum(profit_money) as profit_money'),DB::raw('sum(recharge_money) as recharge_money'),DB::raw('sum(withdraw_money) as withdraw_money'))
            ->where(['user_id' => $user_id,'year' => $year,'month' => $month,])
            ->get();

    }

    public function CalendarDay($year,$month,$user_id)
    {
        return DB::table($this->table)
            ->select('day')
            ->where(['user_id' => $user_id,'year' => $year,'month' => $month,])
            ->get();
    }


}